package com.neusoft.dao.impl;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidPooledConnection;
import com.neusoft.dao.BaseDao;
import com.neusoft.dao.UmsAdminDao;
import com.neusoft.model.UmsAdmin;
import com.neusoft.utils.ClassUtil;

import java.sql.Connection;

/**
 * @Author: duan
 * @Date: Create in 10:09 2020/10/28
 */
public class UmsAdminDaoImpl extends BaseDao<UmsAdmin> implements UmsAdminDao {
    private DruidDataSource dataSource;

    public UmsAdminDaoImpl setDataSource(DruidDataSource dataSource) {
        this.dataSource = dataSource;
        return this;
    }

    @Override
    protected Connection getConn() {
        try {
            DruidPooledConnection connection = dataSource.getConnection();
            return connection;
        } catch (Exception e) {
            e.printStackTrace();
        }

        return null;
    }

    @Override
    public boolean insert(UmsAdmin bean) {
        String sql = ClassUtil.generateInsertSqlFromObject(bean, "ums_admin");

//        return doIUD(sql, bean.getId(), bean.get);
        return false;
    }

    @Override
    public boolean update(UmsAdmin bean) {
        return false;
    }

    @Override
    public boolean delete(Long id) {
        System.out.println("删除id为" + id + "的记录成功");
        return false;
    }
}
